import {
	get,
	post,
	put,
	del
} from '@/utils/request.js'

/**
 * 商家订阅和取消订阅
 */
export const businessSubscribeUpdateStateApi = (data) => {
	return put('/businessSubscribe/updateState', data)
}

/**
 * 发布活动
 */
export const releaseApi = (data) => {
	return post('/businessActive/release', data)
}

/**
 * 发布拼团活动
 */
export const releaseGroupBuyApi = (data) => {
	return post('/businessActive/releaseGroupBuy', data)
}

/**
 * 修改活动
 */
export const businessActiveUpdateApi = (data) => {
	return put('/businessActive/update', data)
}

/**
 * 删除活动
 */
export const businessActiveDeleteApi = (id) => {
	return del(`/businessActive/delete?id=${id}`)
}

/**
 * 下架活动
 */
export const businessActiveDownApi = (id) => {
	return post(`/businessActive/down?id=${id}`)
}


/**
 * 我的活动列表
 */
export const getMyActiveApi = (data) => {
	return get('/businessActive/pageMyActive', data)
}

/**
 * 我的活动详情(去发布)
 */
export const myActiveDetailApi = (id) => {
	return get(`/businessActive/myActiveDetails?id=${id}`)
}

/**
 * 选择团长列表（供创建活动时设置分销佣金调用）
 */
export const selectAgentApi = () => {
	return get(`/group/listBusinessSelectAgent`)
}

/**
 * 我的经纪人分页条件列表
**/ 
export const pageMyAgent = (data) => {
	return get(`/business/pageMyAgent`,data)
}
/**
 * 我的策划人分页条件列表
**/ 
export const pageMyBusiness = (data) => {
	return get(`/business/pageMyBusiness`,data)
}
/**
 * 商家邀请经济人
**/ 
export const inviteAgent = (data) => {
	return post('/business/inviteAgent', data)
}
/**
 * 商家邀请商户
**/ 
export const inviteMerchant = (data) => {
	return post('/business/inviteMerchant', data)
}
/**
 * 商家主页
 */
export const getHomePageApi = (id) => {
	return get(`/business/getHomePage?id=${id}`)
}

/**
 * 编辑商家主页
 */
export const updateHomePageApi = (data) => {
	return put('/business/updateHomePage', data)
}

/**
 * 分享商家主页
 */
export const shareHomePageApi = (data) => {
	return post('/business/shareHomePage', data)
}

/**
 * 分享积分商城主页
 */
export const shareMallPageApi = (data) => {
	return get('/businessPointsMall/share', data)
}

/**
 * 商家主页活动列表
 */
export const pageHomeActiveApi = (data) => {
	return get('/business/pageHomeActive', data)
}
/***
*商家解除绑定经纪人分销关系
**/ 
export const unBindAgent = (data) => {
	return post('/business/unBindAgent', data)
}
// 角色管理主页
export const businessAgentIndex = (data) => {
	return get('/business/businessAgentIndex', data)
}

// 佣金列表
export const pageAgentCommission = (data) => {
	return get('/business/pageAgentCommission', data)
}
// 经纪人专属佣金设置
export const saveAgentCommission = (data) => {
	return put('/business/saveAgentCommission', data)
}

/**
 * 获取商家发布活动限制参数
 */
export const getActiveLimitApi = () => {
	return get('/business/getActiveLimit')
}

/**
 * 次卡购买列表
 */
export const getMerchantCardListApi = (data) => {
	return get('/merchantCard/page', data)
}

/**
 * 创建订单，返回充值订单号
 */
export const merchantCardCreateOrderApi = (data) => {
	return post('/merchantCard/createOrder', data)
}

/**
 * 立即支付，唤起第三方支付
 */
export const merchantCardPayApi = (data) => {
	return post('/merchantCard/pay', data)
}
/***
*商家解除绑定商户
**/ 
export const unBindMerchant = (data) => {
	return post('/business/unBindMerchant', data,{hideErrorToast:true})
}
/***
*
经纪人绑定商家
**/ 
export const bindBusiness = (data) => {
	return post('/agentEnterApply/bind', data,{hideErrorToast:true})
}
/***
*
经纪人绑定商家-预绑定
**/ 
export const bindPreApplyBusiness = (data,options = {}) => {
	options.hideErrorToast = true
	return post('/agentBindApply/preApply', data,options)
}
/***
*通过邀请商家邀请码获取商家部分信息
**/ 
export const getByInviteCode = (data,options) => {
	return get('/business/getByInviteCode', data,options)
}

// 获取经纪人入驻状态
export const getEnterInfoState = () => {
	return get('/agentEnterApply/getEnterInfoState')
}
// 判断邀请码是否失效
export const validSettleCode = (data) => {
	return get('/businessEnterApply/validSettleCode',data)
}

/***
*
经纪人申请绑定
**/ 
export const agentBindApply = (data) => {
	return post('/agentBindApply/apply', data,{hideErrorToast:true})
}

/***
*
经纪人解除与商家的分销关系
**/ 
export const unBindMyBusiness = (data) => {
	return post('/business/unBindMyBusiness', data)
}